package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.DtsRegionService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * projectName:bj-2107-code
 * author:zxf
 * time:2021/12/2 10:02
 * description:
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/admin/region")
public class AdminRegionController {

    @Autowired
    private DtsRegionService dtsRegionService;

    @RequestMapping("/list")
    public Object list(
            @RequestParam(name = "page" ,defaultValue = "1", required = false) Integer page ,
            @RequestParam(name = "limit" ,defaultValue = "20", required = false) Integer limit ,
            String name ,
            Integer code){
        // 分页查询
        IPage<DtsRegion> ipage = dtsRegionService.findPage(page, limit, name, code);
        Map<String,Object> data = new HashMap<>();
        data.put("total" , ipage.getTotal());
        data.put("items" , ipage.getRecords());

        return ResponseUtil.ok(data);
    }

}